package com.mit.wx.wx.dto;

import com.mit.wx.util.xml.CDataConverter;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 2018/10/13 Create by 郭文梁
 * TargetVideoMessage
 * 目标微信视频消息
 *
 * @author 郭文梁
 * @date 2018/10/13
 */
@EqualsAndHashCode(callSuper = true)
@Data
@XStreamAlias("xml")
public class TargetVideoMessage extends TargetMessage {
    @XStreamAlias("Video")
    private Video video;

    public TargetVideoMessage() {
        setMsgType(WxMessages.TYPE_VIDEO);
    }

    public TargetVideoMessage mediaId(String mediaId) {
        video().setMediaId(mediaId);
        return this;
    }

    public TargetVideoMessage title(String title) {
        video().setTitle(title);
        return this;
    }

    public TargetVideoMessage description(String description) {
        video().setDescription(description);
        return this;
    }

    private Video video() {
        if (video == null) {
            video = new Video();
        }
        return video;
    }
}

@Data
class Video {
    @XStreamConverter(CDataConverter.class)
    @XStreamAlias("MediaId")
    private String mediaId;
    @XStreamAlias("Title")
    private String title;
    @XStreamAlias("Description")
    private String description;
}
